﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _03_Tank
{
    enum Direction
    {
        Up, Down, Left, Right
    }
    internal class Movething : GameObject
    {
        public Object _lock = new Object();
        public Bitmap BitmapUp { get; set; }
        public Bitmap BitmapDown { get; set; }
        public Bitmap BitmapLeft { get; set; }
        public Bitmap BitmapRight { get; set; }

        

        public int Speed { get; set; }

        private Direction dir;

        public Direction Dir 
        { 
            get 
            {
                return dir;
            } 
            set 
            {
                dir = value;
                Bitmap bitmap = null;
                switch (dir)
                {
                    case Direction.Up:
                        bitmap = BitmapUp;
                        break;
                    case Direction.Down:
                        bitmap = BitmapDown;
                        break;
                    case Direction.Left:
                        bitmap = BitmapLeft;
                        break;
                    case Direction.Right:
                        bitmap = BitmapRight;
                        break;
                }
                lock (_lock)
                {
                    Width = bitmap.Width;
                    Height = bitmap.Height;
                }
            } 
        }

        protected override Image GetImage()
        {
            Bitmap bitmap = null;

            switch (Dir)
            {
                case Direction.Up:
                    bitmap = BitmapUp;
                    break;
                case Direction.Down:
                    bitmap = BitmapDown;
                    break;
                case Direction.Left:
                    bitmap = BitmapLeft;
                    break;
                case Direction.Right:
                    bitmap = BitmapRight;
                    break;
            }

            bitmap.MakeTransparent(Color.Black);

            return bitmap;
        }


    }
}
